#ifndef __EPOLL_ENTRY_H__
#define __EPOLL_ENTRY_H__

#define BUFFER_LEN 1024

int AcceptCB(int fd);
int RecvCB(int fd);
int SendCB(int fd);

typedef int (*SOCKCALLBACK)(int fd);
typedef struct _ConnItem
{
    int fd;

    char rbuffer[BUFFER_LEN];
    int rlen;
    char wbuffer[BUFFER_LEN];
    int wlen;

    union
    {
        SOCKCALLBACK acceptCallback;
        SOCKCALLBACK recvCallback;
    } arecv;
    SOCKCALLBACK sendCallback;
} ConnItem;

void clearConnItem(ConnItem *item);
void SetNonblocking(int fd);
int SetEvent(int fd, int event, bool addFlag);
int AcceptCB(int fd);
int RecvCB(int fd);
int SendCB(int fd);
int InitServer(unsigned short port);
int EpollEntry(void);

#endif // __EPOLL_ENTRY_H__